#pragma once

#include "LGUIWindow.h"
#include "LGUIMessage.h"

#include <vector>

class LGUIContainer : public LGUIWindow
{
protected:
	int clientX,clientY;
	LGUIWindow *firstChild, *lastChild;
public:
	LGUIContainer(int _x, int _y, int _w, int _h);
	virtual ~LGUIContainer();

	virtual void draw(int xoff, int yoff);
	virtual void penDown(int px, int py);
	virtual void penMove(int px, int py, bool pressed);
	virtual void penUp(int px, int py);
	virtual void keyDown(int key);
	virtual void keyChar(int key);
	virtual void keyUp(int key);
	virtual void redraw();
	virtual LGUIWindow *findChildWithID(int id);
	virtual LGUIWindow *findChildWithUserData(int u);
	virtual std::vector<LGUIWindow *> findChildrenWithUserData(int u);

	void add(LGUIWindow *wnd);
	bool remove(LGUIWindow *wnd);
	void destroyChildren();

	virtual void deliverMessage(LGUIMessage &msg)
	{
		if (parent)
		{
			parent->deliverMessage(msg);
		}
	}
	void bringChildToTop(LGUIWindow *wnd);
	virtual bool isContainer() 
	{
		return true;
	}
};